//
//  ShellSysMessageCell.m
//  VVBTC
//
//  Created by lvzhao on 2019/7/11.
//  Copyright © 2019  吕VV. All rights reserved.
//

#import "ShellSysMessageCell.h"
#import "ShellSysMessageModel.h"


@interface ShellSysMessageCell()

//title
@property (nonatomic,strong)UILabel *titleLab;

//时间
@property (nonatomic,strong)UILabel *timeLabel;

//虚线
@property (nonatomic,strong)UIImageView *lineImageView;

//内容详情
@property (nonatomic,strong)UILabel *detailLab;

@property (nonatomic,strong)ShellSysMessageModel *messageModel;
@end

@implementation ShellSysMessageCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = COLOR_TINT;
        [self setupView];
        
    }
    return self;
}

#pragma mark - setupView
- (void)setupView{
    
   
    
    //titleLab
    self.titleLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textBoldFont(14)];
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(16);
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(K_SCREENWIDTH - 30);
        make.height.mas_equalTo(20);
    }];

    //timeLabel
    self.timeLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0x8D99B2) font:k_textFont(12)];
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLab.mas_bottom).mas_offset(4);
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(K_SCREENWIDTH - 30);
        make.height.mas_equalTo(17);
    }];
    
    [self.contentView addSubview:self.lineImageView];
    [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(71);
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(K_SCREENWIDTH - 30);
        make.height.mas_equalTo(1);
    }];
    self.lineImageView.hidden = YES;

    //detail
    self.detailLab = [UILabel lz_createLabWithTextColor:UIColorHex(0x8D99B2) font:k_textFont(12)];
    self.detailLab.numberOfLines = 0;
    self.detailLab.hidden = YES;
    [self.contentView addSubview:self.detailLab];
    [self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.timeLabel.mas_bottom).mas_offset(27);
        make.right.mas_equalTo(-15);
        make.left.mas_equalTo(15);
        make.height.mas_equalTo(34);
    }];
}

#pragma mark - actions
- (void)setModelObject:(id)modelObject{
    ShellSysMessageModel *messageModel = modelObject;
    self.messageModel = modelObject;
    self.titleLab.text = messageModel.title;
    
    [self.detailLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(messageModel.detailHeight);
    }];
    
    self.timeLabel.text = messageModel.createTime;
    self.detailLab.text = messageModel.content;
    
    self.titleLab.textColor = [messageModel.readFlag isEqualToString:@"Y"] ? UIColorHex(0x4F5D6A):UIColorHex(0xFFFFFF);
    
    
}

#pragma mark - custool

#pragma mark - get && set
- (void)setIsFold:(BOOL)isFold{
    _isFold = isFold;
    
    self.backgroundColor = isFold ? UIColorHex(0x082946):COLOR_TINT;
    
    self.lineImageView.hidden = !isFold;
    self.detailLab.hidden = !isFold;
    
}

- (UIImageView *)lineImageView{
    if(!_lineImageView){
        _lineImageView = [[UIImageView alloc] init];
        _lineImageView.image = [UIImage imageNamed:@"icon_xuxian"];
    }
    return _lineImageView;
}


@end
